#ifndef COMMON_H
#define COMMON_H

#include <time.h>
#include <sys/time.h>

// func: pointer to function
double calcCostTime(int (*func)()) {
    // clock_t start, finish;
    // double  duration;

    // start = clock();
    // func();
    // finish = clock();
    // duration = (double)(finish - start) / CLOCKS_PER_SEC;
    // return 1;

    struct timeval t1,t2;
    double timeuse;
    gettimeofday(&t1,NULL);
    func();
    gettimeofday(&t2,NULL);
    timeuse = t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec)/1000000.0;
    return timeuse;
}

#endif
